package com.service.scheduler.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.service.bean.company.Company;
import com.service.cache.CacheManager;
import com.service.db.DbManager;
import com.service.other.Logger;

/**
 * 将缓存中的速度变化量保存到数据库中
 * @author lj
 * Created on 2015年6月10日
 */
public class SaveWorkSpeedJob implements Job {
	
	public SaveWorkSpeedJob() {
	}

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try {
			//JobKey jk = context.getJobDetail().getKey();
			//String jobName = jk.getName();
			//String jobGroup = jk.getGroup();
			//Logger.println("启动任务 [" + jobGroup + "].[" + jobName + "]");
			for(Company company : CacheManager.instance().workSpeedSaveQueue.keySet()){
				DbManager.instance().dbs.batchSaveWorkSpeeds(company);
			}
			//Logger.println("任务执行完毕，下次启动时间：" + context.getNextFireTime());
		} catch (Exception e) {
			Logger.err(e);
		}
	}

}
